var path = require('path');
var webpack = require('webpack');

//定义路径
var ROOT_PATH = path.resolve(__dirname);
var APP_PATH = path.resolve(ROOT_PATH, 'public');
var ENTRY_PATH = path.resolve(APP_PATH, 'app');
var BUILD_PATH = path.resolve(ROOT_PATH, 'build');

module.exports = {
    entry: {
        index: ENTRY_PATH,
        // vendor: ['jquery'],
        style: ENTRY_PATH + '/style.js',
    },
    output: {
        path: BUILD_PATH,
        filename: "[name].js"
    },
    devtool: 'eval-source-map',
    module: {
        loaders: [
            {
                test: /\.css$/,
                loaders: ['style', 'css']
            },
            {
                test: /\.styl$/,
                loaders: ['style', 'css', 'stylus'],
                include: APP_PATH
            },
            {
                test: /\.js$/,
                include: APP_PATH,
                loader: 'babel-loader'
            },
            {
                test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
                loader: 'url-loader?name=[path][name].[ext]',
                include: APP_PATH
            }
        ]
    },
    stylus: {
        use: [require('nib')()],
        import: ['~nib/lib/nib/index.styl']
    },
    plugins: [
        new webpack.ProvidePlugin({
            $: "jquery",
            jQuery: "jquery",
            "window.jQuery": "jquery"
        })
    ]
};